// 用户状态
import { userAccountLogin } from '@/api/user'
export default {
  namespaced: true,
  state: () => ({
    profile: {
      id: '',
      avatar: '',
      nickname: '',
      account: '',
      mobile: '',
      token: ''
    }
  }),
  mutations: {
    setUser (state, payload) {
      state.profile = payload
    },
    delUser (state) {
      state.profile = {}
    }
  },
  actions: {
    async asyncSetUser (ctx, useInfo) {
      console.log(useInfo)
      const { result } = await userAccountLogin(useInfo)
      ctx.commit('setUser', result)
      // console.log(res)
    },
    login ({ commit }) {
      commit('delUser')
      commit('cart/setList', [], { root: true })
    }
  }
}
